package com.example.a123.umenglogin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.a123.umenglogin.R;
import com.umeng.socialize.common.ResContainer;
import com.umeng.socialize.shareboard.SnsPlatform;

import java.util.ArrayList;

/**
 * ----------BigGod be here!----------/
 * ***┏┓******┏┓*********
 * *┏━┛┻━━━━━━┛┻━━┓*******
 * *┃             ┃*******
 * *┃     ━━━     ┃*******
 * *┃             ┃*******
 * *┃  ━┳┛   ┗┳━  ┃*******
 * *┃             ┃*******
 * *┃     ━┻━     ┃*******
 * *┃             ┃*******
 * *┗━━━┓     ┏━━━┛*******
 * *****┃     ┃神兽保佑*****
 * *****┃     ┃代码无BUG！***
 * *****┃     ┗━━━━━━━━┓*****
 * *****┃              ┣┓****
 * *****┃              ┏┛****
 * *****┗━┓┓┏━━━━┳┓┏━━━┛*****
 * *******┃┫┫****┃┫┫********
 * *******┗┻┛****┗┻┛*********
 * ━━━━━━神兽出没━━━━━━
 * <p>
 * 项目名称：UmengLogin
 * 类描述：
 * 创建人：温泉
 * 创建时间：2017/1/17 14:27
 * 修改人：温泉
 * 修改时间：2017/1/17 14:27
 * 修改备注：
 */

public class ShareAdapter extends BaseAdapter {

    private ArrayList<SnsPlatform> list;
    private Context context;

    public ShareAdapter(Context context,ArrayList<SnsPlatform> list){
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.app_shareadapter,null);
        }

        ImageView img = (ImageView) convertView.findViewById(R.id.adapter_image);
        img.setImageResource(ResContainer.getResourceId(context,"drawable",list.get(position).mIcon));
        TextView tv = (TextView) convertView.findViewById(R.id.name);
        tv.setText(ResContainer.getResourceId(context,"string",list.get(position).mShowWord));

        if(position==list.size()-1){
            convertView.findViewById(R.id.divider).setVisibility(View.GONE);
        }else{
            convertView.findViewById(R.id.divider).setVisibility(View.VISIBLE);
        }

        return convertView;
    }
}
